from selenium import webdriver
from selenium.webdriver.edge.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
import time

# 设置浏览器、启动浏览器
def create_driver():
    options = Options()
    options.add_argument('--no-sandbox')
    options.add_experimental_option("detach", True)
    driver_edge = webdriver.Edge(options=options)
    return driver_edge
driver = create_driver()

# 目的：找到百度中的input框
driver.get("https://baidu.com")
baidu_input = driver.find_element(By.ID, 'chat-textarea')
baidu_input.send_keys("selenium")
time.sleep(1)
baidu_button = driver.find_element(By.ID, 'chat-submit-button')
baidu_button.click()
time.sleep(2)
# 网页后退
driver.back()
time.sleep(2)
# 网页前进
driver.forward()



